<?php
/* 	These code was generated using phpCIGen v 2.a (21/05/2012)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com,
	#CV. Trust Solution, jl. Saronojiwo 2/19 Surabaya, http://www.ts.co.id

	+ Module  		: t_rapk View
	+ Description	: For record view
	+ Filename 		: v_t_rapk.php
 	+ creator  		: 
 	+ Created on 24/Jul/2012 10:52:52

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style type="text/css">
        p { width:650px; }
		.search-item {
			font:normal 11px tahoma, arial, helvetica, sans-serif;
			padding:3px 10px 3px 10px;
			border:1px solid #fff;
			border-bottom:1px solid #eeeeee;
			white-space:normal;
			color:#555;
		}
		.search-item h3 {
			display:block;
			font:inherit;
			font-weight:bold;
			color:#222;
		}
		.icon-send {
			background-image: url(assets/images/icons/book_next.png) !important;
		}
		.search-item h3 span {
			float: right;
			font-weight:normal;
			margin:0 0 5px 5px;
			width:100px;
			display:block;
			clear:none;
		}
    </style>
<script>
/* declare function */
var t_senddata_DataStore;
var t_senddata_ColumnModel;
var t_senddata_ListEditorGrid;
var t_senddata_saveForm;
var t_senddata_SelectedRow;
/* decalare KONSTANSTA */
var FAILED_SAVE="Data gagal disimpan";
var FAILED_CONNECTION="Koneksi database server gagal, hubungi Administrator";
var FAILED_VALID_FORM="Data input belum sempurna";
var FAILED_DELETE_SELECTED="Tidak ada data yang terpilih untuk dihapus";
var FAILED_UPDATE_SELECTED="Tidak ada data yang terpilih untuk diupdate";
var FAILED_DELETE="Data gagal dihapus";
var FAILED_EXCEL="Data gagal diexport ke Excel";
var FAILED_PRINT="Data gagal dicetak";
var FAILED_PERMISSION="Anda tidak mempunyai akses untuk aksi ini";
var CONFIRM_DELETE="Apakah Anda yakin menghapus rekod ini?";
var CONFIRM_MULTI_DELETE="Apakah Anda yakin menghapus rekod-rekod ini?";
var SUCCESS_SAVE="Data sukses disimpan";
var TITLE_LIST="Daftar Data";
var TITLE_FORM="Form Detail Data";
var TITLE_FORM_SEARCH="Pencarian Lanjut";
var BTN_SAVE="Simpan";
var BTN_SEARCH="Cari";
var BTN_CANCEL="Batal";
var BTN_ADD_TITLE="Tambah";
var BTN_EDIT_TITLE="Kirim Data";
var BTN_DELETE_TITLE="Hapus";
var BTN_SEARCH_TITLE="Pencarian";
var BTN_PRINT_TITLE="Cetak";
var BTN_EXCEL_TITLE="Export Excel";
var BTN_REFRESH_TITLE="Refresh";
var BTN_ADD_TOOLTIP="Tambah Data Baru";
var BTN_EDIT_TOOLTIP="Ubah Data";
var BTN_DELETE_TOOLTIP="Hapus Data";
var BTN_SEARCH_TOOLTIP="Pencarian Data Lanjut";
var BTN_SIMPLE_SEARCH_TOOLTIP="Pencarian Sederhana";
var BTN_PRINT_TOOLTIP="Cetak Data (html)";
var BTN_EXCEL_TOOLTIP="Export ke bentuk Excel";
var BTN_REFERSH_TOOLTIP="Refresh Data";
var INFO_REQUIRED="Wajib diisi";
var PERMISSION="RCUD";
//declare konstant
var post2db = 'CREATE';
var msg = 'created';
var pageS=15;

/* on ready fuction */
Ext.onReady(function(){
  	Ext.QuickTips.init();	/* Initiate quick tips icon */
  	
  	Ext.util.Format.comboRenderer = function(combo){
  	    return function(value){
  	        var record = combo.findRecord(combo.valueField, value);
  	        return record ? record.get(combo.displayField) : combo.valueNotFoundText;
  	    };
  	};
  	
  	/* START DATA */
	t_add_datappn = new Ext.data.Store({
		id: 't_project_datappn',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_public_function&m=get_ppn',
			method: 'POST'
		}),
		baseParams:{task: "LIST", start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'setup_ppn'
		},[
			{name: 'setup_ppn', type: 'int', mapping: 'setup_ppn'}
		]),
		sortInfo:{field: 'setup_ppn', direction: "ASC"}
	});
	t_add_datappn.load({params: {start: 0, limit: pageS}});
  	t_senddata_DataStore = new Ext.data.Store({
		id: 't_senddata_DataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_senddata&m=get_action',
			method: 'POST'
		}),
		baseParams:{task: "LIST", start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total'
		},[
			{name: 'branch_id', type: 'string', mapping: 'branch_id'},
			{name: 'branch_name', type: 'string', mapping: 'branch_name'},
			{name: 'project_id', type: 'string', mapping: 'project_id'},
			{name: 'project_name', type: 'string', mapping: 'project_name'},
			{name: 'project_code', type: 'string', mapping: 'project_code'},
			{name: 'job_id', type: 'string', mapping: 'job_id'},
			{name: 'job_name', type: 'string', mapping: 'job_name'},
			{name: 'vendor_name', type: 'string', mapping: 'vendor_name'},
			{name: 'vendor_id', type: 'string', mapping: 'vendor_id'},
			{name: 'vendor_address', type: 'string', mapping: 'vendor_address'},
			{name: 'vendor_cp', type: 'string', mapping: 'vendor_cp'},
			{name: 'kontrak_date', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'kontrak_date'},
			{name: 'data_id', type: 'int', mapping: 'data_id'},
			{name: 'kontrak_no', type: 'string', mapping: 'kontrak_no'},
			{name: 'kontrak_begin', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'kontrak_begin'},
			{name: 'kontrak_end', type: 'date', dateFormat: 'Y-m-d H:i:s', mapping: 'kontrak_end'},
			{name: 'data_type', type: 'string', mapping: 'data_type'}
		]),
		sortInfo:{field: 'project_code', direction: "ASC"}
	});
  	t_senddata_DataStore.load({params: {start: 0, limit: pageS}});	// load DataStore
  	
	var badet_reader=new Ext.data.JsonReader({
		root: 'results',
		totalProperty: 'total',
		id: 'badet_id'
	},[
	/* dataIndex => insert intoperawatan_ColumnModel, Mapping => for initiate table column */
			{name: 'badet_id', type: 'int', mapping: 'badet_id'},
			{name: 'jobdet_id', type: 'int', mapping: 'jobdet_id'}, 
			{name: 'jobdet_name', type: 'string', mapping: 'jobdet_name'},
			{name: 'kompdet_vol', type: 'float', mapping: 'kompdet_vol'},
			{name: 'unit_id', type: 'int', mapping: 'unit_id'},
			{name: 'unit_name', type: 'string', mapping: 'unit_name'},
			{name: 'kompdet_price', type: 'float', mapping: 'kompdet_price'}
	]);
	
	var badetDataStore = new Ext.data.Store({
		id: 'badetDataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_kontrak&m=badet_list', 
			method: 'POST'
		}),
		reader: badet_reader
	});
	
	var t_senddata_adendumreader = new Ext.data.JsonReader({
		root : 'results',
		totalProperty : 'total',
		id : 'add_id'
	},[
		{ name : 'add_id', type : 'string',mapping : 'add_id'},
		{ name : 't_kontrak_id', type : 'string',mapping : 't_kontrak_id'},
		{ name : 'add_type', type : 'string',mapping : 'add_type'},
		{ name : 'add_seq', type : 'string',mapping : 'add_seq'},
		{ name : 'add_reqdate', type : 'date', dateFormat: 'Y-m-d H:i:s',mapping : 'add_reqdate'},
		{ name : 'add_reqno', type : 'string',mapping : 'add_reqno'},
		{ name : 'add_accdate', type : 'date', dateFormat : 'Y-m-d H:i:s',mapping : 'add_accdate'},
		{ name : 'add_accno', type : 'string',mapping : 'add_accno'},
		{ name : 'add_date', type : 'date', dateFormat: 'Y-m-d H:i:s',mapping : 'add_date'},
		{ name : 'add_begin', type : 'date', dateFormat: 'Y-m-d H:i:s',mapping : 'add_begin'},
		{ name : 'add_end', type : 'date', dateFormat: 'Y-m-d H:i:s',mapping : 'add_end'},
		{ name : 'add_value', type : 'int',mapping : 'add_value'},
		{ name : 'add_no', type : 'string',mapping : 'add_no'}
	]);
	
	var t_senddata_adendumDataStore = new Ext.data.Store({
		id : 't_senddata_adendumDataStore',
		proxy : new Ext.data.HttpProxy({
			url : 'index.php?c=c_t_senddata&m=get_dataadendum',
			method : 'POST'
		}),
		reader : t_senddata_adendumreader,
		sortInfo : { field : 'add_id', direction : 'ASC'}
	});

	var pasalDataStore = new Ext.data.Store({
		id: 'pasalDataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_senddata&m=get_pasal_all', 
			method: 'POST'
		}),
		baseParams:{task: "LIST"}, // parameter yang di $_POST ke Controller
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'pasal_id'
		},[
		/* dataIndex => insert intotbl_s_cabang_ColumnModel, Mapping => for initiate table column */ 
			{name: 'pasal_id', type: 'int', mapping: 'pasal_id'}, 
			{name: 'pasal_seq', type: 'int', mapping: 'pasal_seq'}, 
			{name: 'pasal_no', type: 'string', mapping: 'pasal_no'},
			{name: 'pasal_title', type: 'string', mapping: 'pasal_title'},
			{name: 'pasal_content', type: 'string', mapping: 'pasal_content'},
			{name: 'pasal_content_partial', type: 'string', mapping: 'pasal_content_partial'}
		])
	});
  	/* END DATA */
  	
  	
  	/* START FORM */
	//detail
	var senddatadet_rapkdet_idField = new Ext.form.NumberField({
		id: 'senddatadet_rapkdet_idField',
		allowDecimals: true,
		allowNegative: false,
		blankText: '0',
		maskRe: /([0-9]+)$/
	});

	var senddata_jumlah_cfField = new Ext.form.TextField({
		id: 'senddata_jumlah_cfField',
		fieldLabel: 'Jumlah ',
		allowNegatife : false,
		enableKeyEvents: true,
		itemCls: 'rmoney',
		width: 160,
		maskRe: /([0-9]+)$/ 
	});

	var senddata_ppn_cfField = new Ext.form.TextField({
		id: 'senddata_ppn_cfField',
		fieldLabel: 'PPN ',
		allowNegatife : false,
		enableKeyEvents: true,
		itemCls: 'rmoney',
		width: 160,
		maskRe: /([0-9]+)$/ 
	});
	
	var senddata_nk_cfField = new Ext.form.TextField({
		id: 'senddata_nk_cfField',
		fieldLabel: '<span style="font-weight:bold">NK (Rp)</span>',
		allowNegatife : false,
		enableKeyEvents: true,
		itemCls: 'rmoney',
		width: 160,
		maskRe: /([0-9]+)$/ 
	});
	
	var senddata_jobdet_totalGroup = new Ext.form.FieldSet({
		title: '-',
		labelWidth: 140,
		autoHeight: true,
		collapsible: false,
		layout:'form',
		frame: true,
		items:[senddata_jumlah_cfField, senddata_ppn_cfField, senddata_nk_cfField]
	});
	
	//column model jobdet
	var badetColumnModel = new Ext.grid.ColumnModel(
		[{
			header: 'Jenis, Merk, dan Ukuran Material',
			id: 'jobdet_jenis_merk_ukuran',
			dataIndex: 'jobdet_name'
		},
		{
			header: 'Vol',
			dataIndex: 'kompdet_vol',
			width: 90,
			sortable: false,
			align: 'right',
			renderer: Ext.util.Format.numberRenderer('0.000/i')
		},
		{
			header: 'Sat',
			dataIndex: 'unit_name',
			width: 90,
			sortable: false
		},
		{
			header: 'Harga',
			dataIndex: 'kompdet_price',
			width: 90,
			sortable: false,
			align: 'right',
			renderer: Ext.util.Format.numberRenderer('0.000/i')
		},
		{
			header: 'Jumlah',
			width: 100,
			sortable: false,
			renderer: function(v, params, record){
				return Ext.util.Format.number(record.data.kompdet_vol * record.data.kompdet_price,'0.000/i');
            }
		}]
	);
	badetColumnModel.defaultSortable= true;
	
	//detail list editor grid jobdet
	var badetListGrid =  new Ext.grid.GridPanel({
		id: 'badetListGrid',
		//el: 'fp_m_jobdet',
		title: 'Detail Jenis Pekerjaan',
		height: 250,
		width: 780,
		autoScroll: true,
		store: badetDataStore, // DataStore
		colModel: badetColumnModel, // Nama-nama Columns
		enableColLock:false,
		region: 'center',
        margins: '0 5 5 5',
		frame: true,
		autoExpandColumn: 'jobdet_jenis_merk_ukuran',
		//clicksToEdit:2, // 2xClick untuk bisa meng-Edit inLine Data
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:false},
		bbar: new Ext.PagingToolbar({
			pageSize: pageS,
			store: badetDataStore,
			displayInfo: true
		}),
	});
	
	
	//Form Create/Update
	var senddata_idField = new Ext.form.NumberField({
		id: 'senddata_idField',
		fieldLabel: 'senddata Id ',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		hidden: true,
		maskRe: /([0-9]+)$/
	});
	var t_ba_idField = new Ext.form.NumberField({
		id: 't_ba_idField',
		fieldLabel: 'BA Id ',
		allowNegatife : false,
		blankText: '0',
		allowDecimals: false,
		anchor: '95%',
		hidden: true,
		maskRe: /([0-9]+)$/
	});
	var senddata_branchField = new Ext.form.TextField({
		id: 'senddata_branchField',
		fieldLabel: 'Cabang',
		readOnly: true,
		width: 250
	});
	var senddata_projectField = new Ext.form.TextField({
		id: 'senddata_projectField',
		fieldLabel: 'Kode Proyek',
		readOnly: true,
		width: 250
	});
	var senddata_projectNameField = new Ext.form.TextField({
		id: 'senddata_projectNameField',
		fieldLabel: 'Nama Proyek',
		width: 250,
		readOnly: true
	});
	var senddata_jobField = new Ext.form.TextField({
		id: 'senddata_jobField',
		fieldLabel: 'Pengadaan',
		readOnly: true,
		width: 250
	});
	var senddata_vendorField = new Ext.form.TextField({
		id: 'senddata_vendorField',
		fieldLabel: 'Nama Subkont',
		maxLength: 45,
		readOnly: true,
		width: 250
	});
	var senddata_vendor_addressField = new Ext.form.TextArea({
		id: 'senddata_vendor_addressField',
		fieldLabel: 'Alamat',
		readOnly: true,
		width: 250
	});
	var senddata_vendor_wakilField = new Ext.form.TextField({
		id: 'senddata_vendor_wakilField',
		fieldLabel: 'Wakil Subkont',
		maxLength: 45,
		readOnly: true,
		width: 250
	});
	var senddata_dateField = new Ext.form.DateField({
		id: 'senddata_dateField',
		fieldLabel: 'Tgl Kontrak',
		format : 'l, F d, Y',
		width: 250
	});
	var senddata_noField = new Ext.form.TextField({
		id: 'senddata_noField',
		fieldLabel: 'No. Kontrak',
		maxLength: 45,
		width: 250
	});
	var senddata_btnsearch_noField= new Ext.Button({
		tooltip: 'Apakah No. Surat sudah pernah digunakan?',
		iconCls:'icon-search',
		handler: nosenddata_validation
	});
	var senddata_pelaksanaan_datestartField= new Ext.form.DateField({
		id: 'senddata_pelaksanaan_datestartField',
		fieldLabel: 'Awal Pelaksanaan',
		format : 'l, F d, Y',
		width: 250
	});
	var senddata_pelaksanaan_dateendField= new Ext.form.DateField({
		id: 'senddata_pelaksanaan_dateendField',
		fieldLabel: 'Akhir Pelaksanaan',
		format : 'l, F d, Y',
		width: 250
	});
	var m_proccomboboxStore = new Ext.data.Store({
		id: 'm_proccomboboxStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_t_senddata&m=getdata_doctrac_mproc', 
			method: 'POST'
		}),
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total',
			id: 'proc_id'
		},[
			{name: 'proc_id', type: 'int', mapping: 'proc_id'},
			{name: 'proc_name', type: 'string', mapping: 'proc_name'}
		]),
		sortInfo:{field: 'proc_name', direction: "ASC"}
	});
	var m_proccombobox = new Ext.form.ComboBox({
		id: 'm_proccombobox',
		fieldLabel: 'Jenis Procurement <font color=red>*</font>',
		store: m_proccomboboxStore,
		mode: 'remote',
		hidden : true,
		displayField:'proc_name',
		valueField: 'proc_id',
        editable: false,
		width : 250,
		pageSize: 15,
		forceSelection: true,
		triggerAction: 'all',
		allowBlank: false,
	});
	
	var t_senddata_btn_Save = new Ext.Button({
		text: 'Kirim Data',
		// handler: t_senddata_save
		handler: t_senddata_sendfunction
	});
	/* start field data adendum */
		var senddata_addreqDateField= new Ext.form.DateField({
			id: 'senddata_addreqDateField',
			fieldLabel: 'Tgl Permohonan Adendum',
			format : 'l, F d, Y',
			//disabledDays: [0, 6],
			anchor: '95%'
		});
		var senddata_addreqNoField= new Ext.form.TextField({
			id: 'senddata_addreqNoField',
			fieldLabel: 'No. Surat Permohonan Adendum',
			anchor: '95%',
			readOnly: false
		});
		var senddata_addaccDateField= new Ext.form.DateField({
			id: 'senddata_addaccDateField',
			fieldLabel: 'Tgl Persetujuan Adendum',
			name: 'senddata_addaccDateField',
			format : 'l, F d, Y',
			anchor: '95%'
		});
		var senddata_addaccNoField= new Ext.form.TextField({
			id: 'senddata_addaccNoField',
			fieldLabel: 'No. Surat Persetujuan Adendum',
			anchor: '95%',
			readOnly: false
		});
		var senddata_adddateField= new Ext.form.DateField({
			id: 'senddata_adddateField',
			fieldLabel: 'Tgl Kontrak Adendum',
			format : 'l, F d, Y',
			anchor: '95%'
		});
		var senddata_addnoField = new Ext.form.TextField({
			id: 'senddata_addnoField',
			fieldLabel: 'No. Kontrak Adendum',
			maxLength: 45,
			allowBlank: false,
			width: 250
		});
		var senddata_addjangkawaktuField = new Ext.form.NumberField({
			id: 'senddata_addjangkawaktuField',
			fieldLabel: 'Jangka Waktu',
			allowDecimals: false,
			allowNegative: false,
			blankText: '0',
			width: 50,
			enableKeyEvents: true,
			maskRe: /([0-9]+)$/
		});
		senddata_addjangkawaktuField.on('keyup', function(){
			var newdate = new Date();
			newdate.setTime(senddata_addkontrakend_dateField.getValue().getTime() + (senddata_addjangkawaktuField.getValue() * 24 * 3600 * 1000));
			senddata_addpelaksanaan_dateendField.setValue(newdate.format('Y-m-d'));
		});
		var senddata_addbegin_dateField = new Ext.form.DateField({
			id: 'senddata_addbegin_dateField',
			fieldLabel: 'Waktu Awal Adendum',
			format : 'l, F d, Y',
			allowBlank: false,
			readOnly: true,
			width: 200
		});
		var senddata_addkontrakend_dateField = new Ext.form.DateField({
			id: 'senddata_addkontrakend_dateField',
			fieldLabel: 'Akhir Waktu Pelaksanaan',
			format : 'l, F d, Y',
			allowBlank: false,
			readOnly: true,
			width: 200
		});
		var senddata_addpelaksanaan_datestartField = new Ext.form.DateField({
			id: 'senddata_addpelaksanaan_datestartField',
			fieldLabel: 'Awal Pelaksanaan Adendum',
			format : 'l, F d, Y',
			allowBlank: false,
			readOnly: true,
			width: 250
		});
		var senddata_addpelaksanaan_dateendField = new Ext.form.DateField({
			id: 'senddata_addpelaksanaan_dateendField',
			fieldLabel: 'Akhir Pelaksanaan Adendum',
			format : 'l, F d, Y',
			allowBlank: false,
			readOnly: true,
			width: 250
		});
		var senddata_addvalueField = new Ext.form.NumberField({
			id: 'senddata_addvalueField',
			allowDecimals: true,
			allowNegative: false,
			blankText: '0',
			maskRe: /([0-9]+)$/
		});
		var senddata_addvalue_cfField = new Ext.form.TextField({
			id: 'senddata_addvalue_cfField',
			fieldLabel: 'Nilai Kontrak Adendum (Rp)',
			allowNegatife : false,
			enableKeyEvents: true,
			itemCls: 'rmoney',
			width: 250,
			readOnly: true,
			maskRe: /([0-9]+)$/ 
		});
		var senddata_adddataAddGroup = new Ext.form.FieldSet({
			title: 'Data Addendum',
			labelWidth: 200,
			hidden : true,
			width : 500,
			autoHeight: true,
			collapsible: false,
			layout:'form',
			frame: false,
			items:[senddata_addreqDateField, senddata_addreqNoField, senddata_addaccDateField, senddata_addaccNoField, senddata_adddateField, senddata_addnoField, /* senddata_addjangkawaktuField, */
				   senddata_addpelaksanaan_datestartField, senddata_addpelaksanaan_dateendField,senddata_addvalue_cfField]
		});
	/* end field data adendum */
	t_senddata_saveForm = new Ext.FormPanel({
		labelAlign: 'left',
		title: TITLE_FORM,
		bodyStyle:'padding:5px',
		autoHeight:true,
		width: 800,
		collapsible: true,
		frame: true,
		renderTo: 'elwindow_t_senddata_save',
		layout:'form',
		items:[{
			layout: 'column',
			border: false,
			items:[{
				columnWidth:0.5,
				layout: 'form',
				border:false,
				items:[senddata_idField ,t_ba_idField ,senddata_branchField ,senddata_projectField ,senddata_projectNameField ,senddata_jobField
				, senddata_dateField, senddata_noField]
			},{
				columnWidth:0.5,
				layout: 'form',
				border:false,
				items:[senddata_pelaksanaan_datestartField,senddata_pelaksanaan_dateendField,senddata_vendorField, senddata_vendor_addressField, senddata_vendor_wakilField,m_proccombobox]
			}]
		},senddata_adddataAddGroup,badetListGrid ,senddata_jobdet_totalGroup
		,new  Ext.form.Label({html:'Keterangan : <font color=red>*</font>  '+INFO_REQUIRED }) ],
		buttons: [t_senddata_btn_Save
			,{
				text: BTN_CANCEL,
				handler: function(){
					t_senddata_reset_form();
				}
			}
		]
	});
	
	//start main grid panel
	t_senddata_ColumnModel = new Ext.grid.ColumnModel(
		[{
			header: 'Project Id',
			dataIndex: 'data_id',
			width: 150,
			sortable: false,
			hidden: true
		},
		{
			header: 'Cabang',
			dataIndex: 'branch_name',
			width: 150,
			sortable: false
		},
		{
			header: 'Kode Proyek',
			dataIndex: 'project_code',
			width: 150,
			sortable: false
		},
		{
			header: 'Nama Proyek',
			dataIndex: 'project_name',
			width: 150,
			sortable: false
		},
		{
			header: 'Pengadaan',
			dataIndex: 'job_name',
			width: 150,
			sortable: false
		},
		{
			header: 'Nomor Kontrak',
			dataIndex: 'kontrak_no',
			width: 150,
			sortable: false
		},{
			header: 'Jenis',
			dataIndex: 'data_type',
			width: 150,
			sortable: false
		},{
			header: 'Nama Vendor',
			dataIndex: 'vendor_name',
			width: 150,
			sortable: false
		}	]);

	t_senddata_ColumnModel.defaultSortable= true;
	/* End of Function */

    /* Button Control */
    t_senddata_gbtn_update=new Ext.Button({
	    text: BTN_EDIT_TITLE,
		tooltip: BTN_EDIT_TOOLTIP,
		iconCls:'icon-send',
		handler: t_senddata_confirm_update
	});

    t_senddata_gbtn_cetak=new Ext.Button({
	    text: 'Cetak',
		tooltip: 'Cetak PDF',
		iconCls:'icon-update',
		disabled: true,
		handler: function(){
			var ba_id_field = t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('ba_id');
			var branch_id_field = t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('branch_id');
			var project_id_field = t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('project_id');
			var job_id_field = t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('job_id');
			
			Ext.Ajax.request({
				waitMsg: 'Please wait...',
				url: 'index.php?c=c_t_senddata&m=senddata_print',
				params: {
					ba_id: ba_id_field
					//branch_id: branch_id_field,
					//project_id: project_id_field,
					//job_id: job_id_field
				},
				success: function(response){
					win = window.open('./print/senddata.pdf', '_blank');
				},
				failure: function(response){
					Ext.MessageBox.show({
						   title: 'Error',
						   msg: FAILED_CONNECTION,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'database',
						   icon: Ext.MessageBox.ERROR
					});
				}
			});
		}
	});

	t_senddata_ListEditorGrid =  new Ext.grid.EditorGridPanel({
		id: 't_senddata_ListEditorGrid',
		el: 'fp_t_senddata',
		title: TITLE_LIST,
		autoHeight: true,
		collapsible: true,
		store: t_senddata_DataStore, // DataStore
		cm: t_senddata_ColumnModel, // Nama-nama Columns
		enableColLock:false,
		frame: true,
		clicksToEdit:2, // 2xClick untuk bisa meng-Edit inLine Data
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:true },
	  	width: 1024,
		bbar: new Ext.PagingToolbar({
			pageSize: pageS,
			store: t_senddata_DataStore,
			displayInfo: true
		}),
		/* Add Control on ToolBar */
		tbar: [
		t_senddata_gbtn_update, '-',
		// t_senddata_gbtn_cetak, '-',
		new Ext.app.SearchField({
			store: t_senddata_DataStore,
			listeners:{
				specialkey: function(f,e){
					if(e.getKey() == e.ENTER){
						t_senddata_DataStore.baseParams={task:'LIST', start:0, limit:pageS};
		            }
				},
				render: function(c){
				Ext.get(this.id).set({qtitle: BTN_SIMPLE_SEARCH_TOOLTIP});
				}
			},
			width: 120
		})/* ,'-',{
			text: BTN_REFRESH_TITLE,
			tooltip: BTN_REFERSH_TOOLTIP,
			handler: t_senddata_reset_search,
			iconCls:'icon-refresh'
		},'-',{
			text: 'Edit Pasal',
			tooltip: 'Edit Pasal',
			handler: pasal_edit,
			iconCls:'icon-refresh'
		} *//*,'-',{
			text: BTN_EXCEL_TITLE,
			tooltip: BTN_EXCEL_TOOLTIP,
			iconCls:'icon-xls',
			handler: t_senddata_export_excel
		}, '-',{
			text: BTN_PRINT_TITLE,
			tooltip: BTN_PRINT_TOOLTIP,
			iconCls:'icon-print',
			handler: t_senddata_print
		}*/
		]
	});
	t_senddata_ListEditorGrid.render();
	/* t_senddata_ListEditorGrid.on('click', function(){
		if(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_no') === null || t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_no') === ""){
			t_senddata_gbtn_update.enable();
			t_senddata_gbtn_cetak.disable();
		}else{
			t_senddata_gbtn_update.disable();
			t_senddata_gbtn_cetak.enable();
		}
	}); */

	//list to editing pasal
	var pasal_grid = new Ext.grid.GridPanel({
        store: pasalDataStore,
        columns: [
            {
                header   : 'ID', 
                width    : 60, 
                sortable : false, 
                hidden   : true,
                dataIndex: 'pasal_id'
            },
            {
                header   : 'No', 
                width    : 50, 
                sortable : false, 
                dataIndex: 'pasal_no'
            },
            {
                header   : 'Judul', 
                width    : 200, 
                sortable : false, 
                dataIndex: 'pasal_title'
            },
            {
            	id		 : 'pasal_content',
                header   : 'Isi', 
                width    : 100, 
                sortable : false, 
                dataIndex: 'pasal_content_partial',
                renderer : function(val){
                	return '<div style="white-space:normal !important;">'+ val +'</div>';
                }
            },
            {
                xtype: 'actioncolumn',
                width: 30,
                items: [{
                    icon   : './assets/images/icons/pencil.png',  // Use a URL in the icon config
                    tooltip: 'Sell stock',
                    handler: function(grid, rowIndex, colIndex) {
                        var rec = pasalDataStore.getAt(rowIndex);
                        //alert("Sell " + rec.get('pasal_id'));
                        pasal_edit_set_form(rec.get('pasal_id'), rec.get('pasal_no'), rec.get('pasal_content'));
                        pasal_editWindow.show();
                    }
                }]
            }
        ],
        stripeRows: true,
        autoExpandColumn: 'pasal_content',
        autoHeight: true
    });
	pasal_listForm = new Ext.FormPanel({
		labelAlign: 'left',
		bodyStyle:'padding:0px',
		autoHeight:true,
		width: 900,
		items:[pasal_grid],
		buttons:[{
			text: 'Selesai',
			handler: function(){
				pasal_listWindow.hide();
			}
		}]
	});
	pasal_listWindow = new Ext.Window({
		id: 'pasal_listWindow',
		title: 'Edit Pasal',
		closable:true,
		closeAction: 'hide',
		width: 1120,
		autoHeight: true,
		x:0,
		y:0,
		plain:true,
		layout: 'fit',
		modal: true,
		renderTo: 'elwindow_pasal_list',
		items: pasal_listForm
	});

	//editing pasal
	var pasal_editIdField = new Ext.form.NumberField({
		id: 'pasal_editIdField',
		allowDecimals: true,
		allowNegative: false,
		blankText: '0',
		hidden: true,
		maskRe: /([0-9]+)$/
	});
	var pasal_editNoField = new Ext.form.TextField({
		id: 'pasal_editNoField',
		fieldLabel: 'No. Pasal',
		readOnly: true,
		width: 250
	});
	var pasal_editContentField = new Ext.ux.TinyMCE({
		fieldLabel: 'Isi Pasal',
		hideLabel: false,
		tinymceSettings: {
			mode : "textareas",
			theme : "advanced",
			plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks",
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,code,|,insertdate,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|",
			theme_advanced_buttons4 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "none",
			theme_advanced_resizing : false,
			theme_advanced_source_editor_height : 500
			//theme_advanced_path : false//,
			//extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
		},
		width: "98%",
		height: "420",
		value: "<h1>Demo</h1><p>Ext.ux.TinyMCE works...</p>"
	});
	pasal_editForm = new Ext.FormPanel({
		labelAlign: 'left',
		bodyStyle:'padding:0px',
		autoHeight:true,
		width: 900,
		frame: true,
		items:[pasal_editIdField, pasal_editNoField, pasal_editContentField],
		buttons:[{
			text: 'Simpan',
			handler: pasal_edit_save
		},{
			text: 'Batal',
			handler: function(){
				pasal_editWindow.hide();
			}
		}]
	});
	pasal_editWindow = new Ext.Window({
		id: 'pasal_editWindow',
		title: 'Editing Pasal',
		closable:true,
		closeAction: 'hide',
		width: 1120,
		autoHeight: true,
		x:0,
		y:0,
		plain:true,
		layout: 'fit',
		modal: true,
		renderTo: 'elwindow_pasal_edit',
		items: pasal_editForm
	});
  	/* END FORM */
  	
  	
  	/* START FUNCTION */
	function get_pk_id(){
		if(post2db=='UPDATE')
			return t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_id');
		return 0;
	}
	
	//validation form
	function is_t_senddata_form_valid(){
		return (senddata_dateField.isValid() && senddata_noField.isValid() && senddata_pelaksanaan_datestartField.isValid() && senddata_pelaksanaan_dateendField.isValid());
	}
	
	//saving data
	function t_senddata_save(){

		var patt=new RegExp("U");
		var patt2=new RegExp("C");
		if(patt.test(PERMISSION)==false && patt2.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{
			if(is_t_senddata_form_valid()){
				var senddata_id_field=null;
				var t_ba_id_field=null;
				var senddata_date_field="";
				var senddata_no_field=null;
				var senddata_begin_field="";
				var senddata_end_field="";
	
				if(senddata_idField.getValue()!== null){senddata_id_field = senddata_idField.getValue();}
				if(t_ba_idField.getValue()!== null){t_ba_id_field = t_ba_idField.getValue();}
				if(senddata_dateField.getValue()!==""){senddata_date_field = senddata_dateField.getValue().format('Y-m-d');}
				if(senddata_noField.getValue()!== null){senddata_no_field = senddata_noField.getValue();}
				if(senddata_pelaksanaan_datestartField.getValue()!==""){senddata_begin_field = senddata_pelaksanaan_datestartField.getValue().format('Y-m-d');}
				if(senddata_pelaksanaan_dateendField.getValue()!==""){senddata_end_field = senddata_pelaksanaan_dateendField.getValue().format('Y-m-d');}
				
	
				Ext.Ajax.request({
					waitMsg: 'Please wait...',
					url: 'index.php?c=c_t_senddata&m=t_senddata_cu',
					params: {
						senddata_id	: senddata_id_field,
						t_ba_id: t_ba_id_field,
						senddata_date: senddata_date_field,
						senddata_no: senddata_no_field,
						senddata_begin: senddata_begin_field,
						senddata_end: senddata_end_field
					},
					success: function(response){
						var result=eval(response.responseText);
						switch(result){
							case 1:
								Ext.MessageBox.alert(post2db+' OK',SUCCESS_SAVE);
								t_senddata_DataStore.reload();
								t_senddata_reset_form();
								break;
							default:
								Ext.MessageBox.show({
								   title: 'Warning',
								   msg: FAILED_SAVE,
								   buttons: Ext.MessageBox.OK,
								   animEl: 'save',
								   icon: Ext.MessageBox.WARNING
								});
								break;
						}
					},
					failure: function(response){
						Ext.MessageBox.show({
							   title: 'Error',
							   msg: FAILED_CONNECTION,
							   buttons: Ext.MessageBox.OK,
							   animEl: 'database',
							   icon: Ext.MessageBox.ERROR
						});
					}
				});
	
			} else {
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_VALID_FORM,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
			}

		}
	}
	// sending data
	function t_senddata_sendfunction(){
		var kontrak_id = "";
		var proc_id = null;
		var jenis_data = "";
		if(senddata_idField.getValue()!== null){kontrak_id = senddata_idField.getValue();}
		jenis_data = t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_type');
			Ext.Ajax.request({
				waitMsg : "Mengirim Data...",
				url : 'index.php?c=c_t_senddata&m=get_action',
				params : {
					kontrak_id : kontrak_id,
					proc_id : proc_id,
					jenis_data : jenis_data,
					task : 'SENDDATA'
				},success : function(response){
					var result = eval(response.responseText);
					switch(result){
						case 0:
							Ext.MessageBox.alert("Sending Success", "Data Sukses Dikirim..");
							t_senddata_reset_form();
							t_senddata_DataStore.load({params: {start: 0, limit: pageS}});
						break;
						default:
							Ext.MessageBox.show({
								   title: 'Warning',
								   msg: "Pengiriman Gagal..",
								   buttons: Ext.MessageBox.OK,
								   animEl: 'save',
								   icon: Ext.MessageBox.WARNING
								});
						break;
					}
				}
			});
	}
	
	//reset form
	function t_senddata_reset_form(){
		senddata_idField.reset();
		senddata_idField.setValue(null);
		t_ba_idField.reset();
		t_ba_idField.setValue(null);
		senddata_projectField.reset();
		senddata_projectField.setValue(null);
		senddata_projectNameField.reset();
		senddata_projectNameField.setValue(null);
		senddata_branchField.reset();
		senddata_branchField.setValue(null);
		senddata_nk_cfField.reset();
		senddata_nk_cfField.setValue(null);
		senddata_jumlah_cfField.reset();
		senddata_jumlah_cfField.setValue(null);
		senddata_ppn_cfField.reset();
		senddata_ppn_cfField.setValue(null);
		senddata_jobField.reset();
		senddata_jobField.setValue(null);
		senddata_vendorField.reset();
		senddata_vendorField.setValue(null);
		senddata_vendor_addressField.reset();
		senddata_vendor_addressField.setValue(null);
		senddata_vendor_wakilField.reset();
		senddata_vendor_wakilField.setValue(null);
		senddata_dateField.reset();
		senddata_dateField.setValue(null);
		senddata_noField.reset();
		senddata_noField.setValue(null);
		senddata_pelaksanaan_datestartField.reset();
		senddata_pelaksanaan_datestartField.setValue(null);
		senddata_pelaksanaan_dateendField.reset();
		senddata_pelaksanaan_dateendField.setValue(null);
		m_proccombobox.setValue(null);
		senddata_addreqDateField.setValue(null);
		senddata_addreqNoField.setValue(null);
		senddata_addaccDateField.setValue(null);
		senddata_addaccNoField.setValue(null);
		senddata_adddateField.setValue(null);
		senddata_addnoField.setValue(null);
		/* senddata_addjangkawaktuField.setValue(null);*/
		senddata_addpelaksanaan_datestartField.setValue(null);
		senddata_addpelaksanaan_dateendField.setValue(null);
		senddata_addvalue_cfField.setValue(null);
		badetListGrid.getStore().removeAll();
	}
	
	//set form
	function t_senddata_set_form(){
		senddata_idField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_id'));
		t_ba_idField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('ba_id'));
		senddata_branchField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('branch_name'));
		senddata_projectField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('project_code'));
		senddata_projectNameField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('project_name'));
		senddata_jobField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('job_name'));
		senddata_vendorField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('vendor_name'));
		senddata_dateField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_date'));
		senddata_noField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_no'));
		senddata_noField.setReadOnly(true);
		senddata_vendor_addressField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('vendor_address'));
		senddata_vendor_wakilField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('vendor_cp'));
		
		senddata_dateField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_date'));
		senddata_noField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_no'));
		senddata_pelaksanaan_datestartField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_begin'));
		senddata_pelaksanaan_dateendField.setValue(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_end'));

		/* if(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_id') == 0){
			senddata_dateField.setReadOnly(true);
			senddata_noField.setReadOnly(false);
			senddata_pelaksanaan_datestartField.setReadOnly(true);
			senddata_pelaksanaan_dateendField.setReadOnly(true);
		}else{
			senddata_dateField.setReadOnly(true);
			senddata_noField.setReadOnly(true);
			senddata_pelaksanaan_datestartField.setReadOnly(true);
			senddata_pelaksanaan_dateendField.setReadOnly(true);
		} */
		senddata_dateField.setReadOnly(true);
		senddata_noField.setReadOnly(true);
		senddata_pelaksanaan_datestartField.setReadOnly(true);
		senddata_pelaksanaan_dateendField.setReadOnly(true);
		senddata_jumlah_cfField.setReadOnly(true);
		senddata_ppn_cfField.setReadOnly(true);
		senddata_nk_cfField.setReadOnly(true);
		if(t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_type') == "Adendum"){
			badetDataStore.proxy.conn.url = 'index.php?c=c_t_senddata&m=adddet_list';
			t_senddata_adendumDataStore.setBaseParam('add_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_id'));
			t_senddata_adendumDataStore.load({
				callback : function(opts, success, response){
					// console.log(t_senddata_adendumDataStore.getAt(0).data);
					senddata_addreqDateField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_reqdate);
					senddata_addreqNoField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_reqno);
					senddata_addaccDateField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_accdate);
					senddata_addaccNoField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_accno);
					senddata_adddateField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_date);
					senddata_addnoField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_no);
					// senddata_addjangkawaktuField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_id);
					senddata_addbegin_dateField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_begin);
					senddata_addkontrakend_dateField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_end);
					senddata_addpelaksanaan_datestartField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_begin);
					senddata_addpelaksanaan_dateendField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_end);
					senddata_addvalueField.setValue(t_senddata_adendumDataStore.getAt(0).data.add_value);
					senddata_addvalue_cfField.setValue(formatCurrency(t_senddata_adendumDataStore.getAt(0).data.add_value));
				}
			});
			senddata_adddataAddGroup.show();
		}else{
			badetDataStore.proxy.conn.url = 'index.php?c=c_t_kontrak&m=badet_list';
			senddata_adddataAddGroup.hide();
		}

		badetDataStore.setBaseParam('branch_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('branch_id'));
		badetDataStore.setBaseParam('project_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('project_id'));
		badetDataStore.setBaseParam('job_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('job_id'));
		badetDataStore.setBaseParam('vendor_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('vendor_id'));
		badetDataStore.setBaseParam('kontrak_no', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('kontrak_no'));
		badetDataStore.setBaseParam('add_id', t_senddata_ListEditorGrid.getSelectionModel().getSelected().get('data_id'));
		badetDataStore.load({
			callback: function(opts, success, response){
				var detail_total = 0;
				for(var i=0; i<badetDataStore.getCount(); i++){
					detail_total += (badetDataStore.getAt(i).data.kompdet_vol * badetDataStore.getAt(i).data.kompdet_price);
				}
				senddata_jumlah_cfField.setValue(formatCurrency(detail_total));

				senddata_ppn_cfField.setValue(formatCurrency(set_valueppn(detail_total)));
				
				senddata_nk_cfField.setValue(formatCurrency(detail_total + set_valueppn(detail_total)));
			}
		});
	}
	
	//update main grid
	function t_senddata_confirm_update(){
		/* only one record is selected here */
		if(t_senddata_ListEditorGrid.selModel.getCount() == 1) {
			post2db='UPDATE';
			msg='updated';
			t_senddata_set_form();
		} else {
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_UPDATE_SELECTED,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
	
	//reset searching
	function t_senddata_reset_search(){
		t_senddata_DataStore.baseParams = { task: 'LIST' };
		t_senddata_DataStore.reload({params: {start: 0, limit: pageS}});
	};
	
	//printing
	function t_senddata_print(){
		var searchquery = "";
		var senddata_id_print=null;
		var senddata_flag_print=null;
		var senddata_code_print=null;
		var senddata_type_print=null;
		var senddata_name_print=null;
		var senddata_shortname_print=null;
		var senddata_pm_print=null;
		var senddata_semcm_print=null;
		var senddata_value_print=null;
		var senddata_start_print_date="";
		var senddata_p1_print_date="";
		var senddata_p2_print_date="";
		var m_branch_print=null;

		if(t_senddata_DataStore.baseParams.query!==null){searchquery = t_senddata_DataStore.baseParams.query;}
		if(t_senddata_DataStore.baseParams.senddata_id!==null){senddata_id_print = t_senddata_DataStore.baseParams.senddata_id;}
		if(t_senddata_DataStore.baseParams.senddata_flag!==null){senddata_flag_print = t_senddata_DataStore.baseParams.senddata_flag;}
		if(t_senddata_DataStore.baseParams.senddata_code!==null){senddata_code_print = t_senddata_DataStore.baseParams.senddata_code;}
		if(t_senddata_DataStore.baseParams.senddata_type!==null){senddata_type_print = t_senddata_DataStore.baseParams.senddata_type;}
		if(t_senddata_DataStore.baseParams.senddata_name!==null){senddata_name_print = t_senddata_DataStore.baseParams.senddata_name;}
		if(t_senddata_DataStore.baseParams.senddata_shortname!==null){senddata_shortname_print = t_senddata_DataStore.baseParams.senddata_shortname;}
		if(t_senddata_DataStore.baseParams.senddata_pm!==null){senddata_pm_print = t_senddata_DataStore.baseParams.senddata_pm;}
		if(t_senddata_DataStore.baseParams.senddata_semcm!==null){senddata_semcm_print = t_senddata_DataStore.baseParams.senddata_semcm;}
		if(t_senddata_DataStore.baseParams.senddata_value!==null){senddata_value_print = t_senddata_DataStore.baseParams.senddata_value;}
		if(t_senddata_DataStore.baseParams.senddata_start!==""){senddata_start_print_date = t_senddata_DataStore.baseParams.senddata_start;}
		if(t_senddata_DataStore.baseParams.senddata_p1!==""){senddata_p1_print_date = t_senddata_DataStore.baseParams.senddata_p1;}
		if(t_senddata_DataStore.baseParams.senddata_p2!==""){senddata_p2_print_date = t_senddata_DataStore.baseParams.senddata_p2;}
		if(t_senddata_DataStore.baseParams.m_branch!==null){m_branch_print = t_senddata_DataStore.baseParams.m_branch;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_t_senddata&m=get_action',
		params: {
			task: "PRINT",
		  	query: searchquery,
			senddata_id : senddata_id_print,
			senddata_flag : senddata_flag_print,
			senddata_code : senddata_code_print,
			senddata_type : senddata_type_print,
			senddata_name : senddata_name_print,
			senddata_shortname : senddata_shortname_print,
			senddata_pm : senddata_pm_print,
			senddata_semcm : senddata_semcm_print,
			senddata_value : senddata_value_print,
		  	senddata_start : senddata_start_print_date,
		  	senddata_p1 : senddata_p1_print_date,
		  	senddata_p2 : senddata_p2_print_date,
			m_branch : m_branch_print,
		  	currentlisting: t_senddata_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
				window.open('./print/t_senddata_printlist.html','t_senddatalist','height=600,width=800,resizable=1,scrollbars=0, menubar=0');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_PRINT,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	
	//exporting excel
	function t_senddata_export_excel(){
		var searchquery = "";
		var senddata_id_2excel=null;
		var senddata_flag_2excel=null;
		var senddata_code_2excel=null;
		var senddata_type_2excel=null;
		var senddata_name_2excel=null;
		var senddata_shortname_2excel=null;
		var senddata_pm_2excel=null;
		var senddata_semcm_2excel=null;
		var senddata_value_2excel=null;
		var senddata_start_2excel_date="";
		var senddata_p1_2excel_date="";
		var senddata_p2_2excel_date="";
		var m_branch_2excel=null;

		if(t_senddata_DataStore.baseParams.query!==null){searchquery = t_senddata_DataStore.baseParams.query;}
		if(t_senddata_DataStore.baseParams.senddata_id!==null){senddata_id_2excel = t_senddata_DataStore.baseParams.senddata_id;}
		if(t_senddata_DataStore.baseParams.senddata_flag!==null){senddata_flag_2excel = t_senddata_DataStore.baseParams.senddata_flag;}
		if(t_senddata_DataStore.baseParams.senddata_code!==null){senddata_code_2excel = t_senddata_DataStore.baseParams.senddata_code;}
		if(t_senddata_DataStore.baseParams.senddata_type!==null){senddata_type_2excel = t_senddata_DataStore.baseParams.senddata_type;}
		if(t_senddata_DataStore.baseParams.senddata_name!==null){senddata_name_2excel = t_senddata_DataStore.baseParams.senddata_name;}
		if(t_senddata_DataStore.baseParams.senddata_shortname!==null){senddata_shortname_2excel = t_senddata_DataStore.baseParams.senddata_shortname;}
		if(t_senddata_DataStore.baseParams.senddata_pm!==null){senddata_pm_2excel = t_senddata_DataStore.baseParams.senddata_pm;}
		if(t_senddata_DataStore.baseParams.senddata_semcm!==null){senddata_semcm_2excel = t_senddata_DataStore.baseParams.senddata_semcm;}
		if(t_senddata_DataStore.baseParams.senddata_value!==null){senddata_value_2excel = t_senddata_DataStore.baseParams.senddata_value;}
		if(t_senddata_DataStore.baseParams.senddata_start!==""){senddata_start_2excel_date = t_senddata_DataStore.baseParams.senddata_start;}
		if(t_senddata_DataStore.baseParams.senddata_p1!==""){senddata_p1_2excel_date = t_senddata_DataStore.baseParams.senddata_p1;}
		if(t_senddata_DataStore.baseParams.senddata_p2!==""){senddata_p2_2excel_date = t_senddata_DataStore.baseParams.senddata_p2;}
		if(t_senddata_DataStore.baseParams.m_branch!==null){m_branch_2excel = t_senddata_DataStore.baseParams.m_branch;}

		Ext.Ajax.request({
		waitMsg: 'Please Wait...',
		url: 'index.php?c=c_t_senddata&m=get_action',
		params: {
			task: "EXCEL",
		  	query: searchquery,
			senddata_id : senddata_id_2excel,
			senddata_flag : senddata_flag_2excel,
			senddata_code : senddata_code_2excel,
			senddata_type : senddata_type_2excel,
			senddata_name : senddata_name_2excel,
			senddata_shortname : senddata_shortname_2excel,
			senddata_pm : senddata_pm_2excel,
			senddata_semcm : senddata_semcm_2excel,
			senddata_value : senddata_value_2excel,
		  	senddata_start : senddata_start_2excel_date,
		  	senddata_p1 : senddata_p1_2excel_date,
		  	senddata_p2 : senddata_p2_2excel_date,
			m_branch : m_branch_2excel,
		  	currentlisting: t_senddata_DataStore.baseParams.task
		},
		success: function(response){
		  	var result=eval(response.responseText);
		  	switch(result){
		  	case 1:
		  		window.open('./print/t_senddata_printlist.xls');
				break;
		  	default:
				Ext.MessageBox.show({
					title: 'Warning',
					msg: FAILED_EXCEL,
					buttons: Ext.MessageBox.OK,
					animEl: 'save',
					icon: Ext.MessageBox.WARNING
				});
				break;
		  	}
		},
		failure: function(response){
			Ext.MessageBox.show({
			   title: 'Error',
			   msg: FAILED_CONNECTION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'database',
			   icon: Ext.MessageBox.ERROR
			});
		}
		});
	}
	
	function nosenddata_validation(){
		Ext.Ajax.request({
			waitMsg: 'Please wait...',
			url: 'index.php?c=c_t_senddata&m=get_nosenddata',
			params: {
				nosenddata: senddata_noField.getValue()
			},
			success: function(response){
				var result=eval(response.responseText);
				if(result==0){
					Ext.MessageBox.show({
					   title: 'Warning',
					   msg: 'No. senddata tidak valid!',
					   buttons: Ext.MessageBox.OK,
					   animEl: 'save',
					   icon: Ext.MessageBox.WARNING
					});
					senddata_noField.reset();
					senddata_noField.setValue(null);
				}
			},
			failure: function(response){
				Ext.MessageBox.show({
					   title: 'Error',
					   msg: FAILED_CONNECTION,
					   buttons: Ext.MessageBox.OK,
					   animEl: 'database',
					   icon: Ext.MessageBox.ERROR
				});
			}
		});
	}

	function pasal_edit(){
		pasalDataStore.load();
		pasal_listWindow.show();
	}

  	function pasal_edit_set_form(id, no, content){
  		if (typeof id == "undefined") {
  	  	    id = 0;
  	  	}
  		if (typeof no == "undefined") {
  	  	    no = "";
  	  	}
		if (typeof content == "undefined") {
  	  	    content = "Tidak ada data";
  	  	}

		pasal_editIdField.setValue(id);
		pasal_editNoField.setValue(no);
		pasal_editContentField.setValue(content);
  	}

  	function pasal_edit_reset_form(){
  		pasal_editIdField.reset();
  		pasal_editIdField.setValue(null);
  		pasal_editNoField.reset();
		pasal_editNoField.setValue(null);
		pasal_editContentField.reset();
		pasal_editContentField.setValue("");
  	}

  	function pasal_edit_save(){

		var patt=new RegExp("U");
		var patt2=new RegExp("C");
		if(patt.test(PERMISSION)==false && patt2.test(PERMISSION)==false){

			Ext.MessageBox.show({
			   title: 'Warning',
			   msg: FAILED_PERMISSION,
			   buttons: Ext.MessageBox.OK,
			   animEl: 'security',
			   icon: Ext.MessageBox.WARNING
			});

		}else{
			var pasal_id_field=0;
			var pasal_content_field="";

			if(pasal_editIdField.getValue()!==null && pasal_editIdField.getValue()!==""){pasal_id_field = pasal_editIdField.getValue();}
			if(pasal_editContentField.getValue()!== null){pasal_content_field = pasal_editContentField.getValue();}

			Ext.Ajax.request({
				waitMsg: 'Please wait...',
				url: 'index.php?c=c_t_senddata&m=pasal_edit_save',
				params: {
					pasal_id	: pasal_id_field,
					pasal_content: pasal_content_field
				},
				success: function(response){
					var result=eval(response.responseText);
					switch(result){
						case 1:
							Ext.MessageBox.alert(' OK',SUCCESS_SAVE);
							pasalDataStore.reload();
							pasal_edit_reset_form();
							pasal_editWindow.hide();
							break;
						default:
							Ext.MessageBox.show({
							   title: 'Warning',
							   msg: FAILED_SAVE,
							   buttons: Ext.MessageBox.OK,
							   animEl: 'save',
							   icon: Ext.MessageBox.WARNING
							});
							break;
					}
				},
				failure: function(response){
					Ext.MessageBox.show({
						   title: 'Error',
						   msg: FAILED_CONNECTION,
						   buttons: Ext.MessageBox.OK,
						   animEl: 'database',
						   icon: Ext.MessageBox.ERROR
					});
				}
			});
	

		}
	}
	function set_valueppn(value){
		var ppn_datarecord = t_add_datappn.getAt(0).data;
		var ppn = ppn_datarecord.setup_ppn;
		var ppn_nilai = value * ppn / 100;
		return Math.ceil(ppn_nilai);
	}
	function set_valueminppn(value){
		var ppn_datarecord = t_add_datappn.getAt(0).data;
		var ppn = ppn_datarecord.setup_ppn;
		var ppn_nilai = value * ppn / 100;
		var valueminppn = value - ppn_nilai;
		return Math.ceil(valueminppn);
	}
  	/* END FUNCTION */

	/* START CONTROL PERMISSION */
	var pattr=new RegExp("R");
	var pattc=new RegExp("C");
	var pattu=new RegExp("U");
	var pattd=new RegExp("D");

	if(pattc.test(PERMISSION)==false){
		
	}else{
		
	}

	if(pattu.test(PERMISSION)==false){
		t_senddata_gbtn_update.setVisible(false);
	}else{
		t_senddata_gbtn_update.setVisible(true);
	}

	if(pattd.test(PERMISSION)==false){
		
	}else{
		
	}

	if(pattc.test(PERMISSION)==false && pattu.test(PERMISSION)==false){
		t_senddata_btn_Save.setVisible(false);
	}else{
		t_senddata_btn_Save.setVisible(true);
	}
	/* END CONTROL PERMISSION */
	
});
</script>
<body style: 'background: url(assets/images/desktop.jpg)'>
<div>
	<div class="col">
		<div id="elwindow_t_senddata_save"></div>
		<div>&nbsp;</div>
		<div id="fp_t_senddata"></div>
		<div id="elwindow_pasal_list"></div>
        <div id="elwindow_pasal_edit"></div>
    </div>
</div>
</body>
</html>